package com.lanlian.cayman.dialog;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

import com.lanlian.cayman.utils.DensityUtil;

public class ColorView extends View {
    boolean select=false;
    int color=0xff4385F3;
    Context context;
    int banjin=0;
    public ColorView(Context context) {
        super(context);
        this.context=context;
    }

    public ColorView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        this.context=context;
    }

    public int getColor() {
        return color;
    }

    public void setColor(int color)
    {
        this.color=color;
    }
    public void setSelect(boolean select)
    {
       this.select=select;
       invalidate();
    }
    public boolean getSelect()
    {
        return select;
    }
    @Override
    public void draw(Canvas canvas) {
        super.draw(canvas);
        banjin=getWidth()/2;


        //设置画笔
        Paint paint=new Paint();
        paint.setAntiAlias(true);
        paint.setColor(color);
        paint.setStyle(Paint.Style.FILL_AND_STROKE);

        //画圆
        canvas.drawCircle(banjin,banjin,banjin-4,paint);

        if(select) {
            //设置画笔
            Paint paint2 = new Paint();
            paint2.setAntiAlias(true);
            paint2.setColor(color);
            paint2.setStyle(Paint.Style.STROKE);
            paint2.setStrokeWidth(2f);

            //画圆
            canvas.drawCircle(banjin, banjin, banjin, paint2);
        }

    }
}
